
import socket
#客户端
import sys
import threading
import time
def read(s):
    try:
        while True:
            reply = s.recv(2048).decode("utf-8")
            time.sleep(2)
            if not reply:
                continue
            print("服务器：", reply)

    except:
        sys.exit(0)
        pass
def write(s):
    while True:
        words=input("请输入:")
        s.sendall(words.encode("utf-8"))
        #reply = s.recv(2048).decode("utf-8")
        #print("服务器回复：", reply)
        if words=="--exit":
            break
    s.close()
if __name__ == '__main__':
    s=socket.socket()
    s.connect(("192.168.100.85",9998))
    print("启动完成",s)
    t1=threading.Thread(target=read,args=(s,))
    t2=threading.Thread(target=write,args=(s,))
    t1.start()
    t2.start()